package cn.yunhe.controller;

import cn.yunhe.model.Page;
import cn.yunhe.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import cn.yunhe.model.User;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class UserController {
    @Resource
    private IUserService userService;
    Page page = new Page();

    @RequestMapping("/findAll")
    /*public ModelAndView findAllUser(String username,int pageSize,int pageNum){
        User user = new User();
        user.setUsername(username);
        Map<String ,Object> cond = new HashMap<String,Object>();
        cond.put("pageSize",pageSize);
        cond.put("pageNum",pageNum);
        cond.put("user",user);
        page = userService.getAllUser(cond);
        ModelAndView mv = new ModelAndView();
        mv.setView(new MappingJackson2JsonView());
        mv.addObject("list",page.getResult());
        mv.addObject("totalPage",page.getTotalPage());
        return mv;
    }*/

    public IUserService getUserService() {
        return userService;
    }

    public void setUserService(IUserService userService) {
        this.userService = userService;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }
}
